<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>通过定位的形式实现</title>
  <style>
      :root {
          --width: 200px;
      }

      .container {
          background: red;

          position: fixed;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);

          width: var(--width);
          height: calc(var(--width) / 2);
      }
  </style>
</head>
<body>
<div class="container"></div>
</body>
</html>
